<?
class printUtils{
	/**
	 * Creates a DOM for XML; Defaults to using pretty print.
	 * @param string $xml XML Blob
	 * @return DomDocument DOM representation of the XML
	 */
	public static function createDOM($xml)
	{
		$dom = new DomDocument();
		$dom->preserveWhitespace = false;
		$dom->loadXML($xml);
		$dom->formatOutput = true;

		return $dom;
	}
	/**
	 * Pretty prints the provided XML.
	 * @param string $xml XML Blob
	 */
	public static function printXML($xml){
		$dom = self::createDOM($xml);
		self::printDOM($dom);
	}

	/**
	 * Pretty prints the provided DOM.
	 * @param DomDocument $dom DOM representation of the XML
	 */
	public static function printDOM($dom){
		echo '<p><pre>' . htmlspecialchars( $dom->saveXML() ) . '</pre></p>';
	}
}
?>